﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;

namespace ApplLogic.ApplClasses
{
    [Serializable]
    public class ApplWorkerStatInWeek
    {
        private DateTime m_WeekStartTime;
        private DateTime m_WeekSEndTime;
        private ApplWorker m_WorkerRef;
        int m_TotalNumberOfShiftsGot;
        int m_TotalWantedShifts;
        int m_TotalForbiddenShifts;
        int m_ShiftsThatAskedAndGot;
        int m_ShiftsThatNotAskedAndGot;
        int m_ShiftsThatAskedNotToBeAndGot;


        public DateTime WeekStartTime
        {
            get { return m_WeekStartTime; }
            set { m_WeekStartTime = value; }
        }

        public DateTime WeekSEndTime
        {
            get { return m_WeekSEndTime; }
            set { m_WeekSEndTime = value; }
        }

        public ApplWorker WorkerRef
        {
            get { return m_WorkerRef; }
            set { m_WorkerRef = value; }
        }

        public int TotalNumberOfShiftsGot
        {
            get { return m_TotalNumberOfShiftsGot; }
            set { m_TotalNumberOfShiftsGot = value; }
        }

        public int TotalWantedShifts
        {
            get { return m_TotalWantedShifts; }
            set { m_TotalWantedShifts = value; }
        }

        public int TotalForbiddenShifts
        {
            get { return m_TotalForbiddenShifts; }
            set { m_TotalForbiddenShifts = value; }
        }

        public int ShiftsThatAskedAndGot
        {
            get { return m_ShiftsThatAskedAndGot; }
            set { m_ShiftsThatAskedAndGot = value; }
        }

        public int ShiftsThatNotAskedAndGot
        {
            get { return m_ShiftsThatNotAskedAndGot; }
            set { m_ShiftsThatNotAskedAndGot = value; }
        }

        public int ShiftsThatAskedNotToBeAndGot
        {
            get { return m_ShiftsThatAskedNotToBeAndGot; }
            set { m_ShiftsThatAskedNotToBeAndGot = value; }
        }

        public double GetPrecentOfShiftsThatWantedAndGot()
        {
            return m_TotalNumberOfShiftsGot != 0
                       ? (double)m_ShiftsThatAskedAndGot / (double)m_TotalNumberOfShiftsGot * 100
                       : 0;
        }

        public double GetPrecentOfShiftsThatGotButNotAsked()
        {
            return m_TotalNumberOfShiftsGot != 0
                       ? (double)m_ShiftsThatNotAskedAndGot / (double)m_TotalNumberOfShiftsGot * 100
                       : 0;
        }

        public double GetPrecentOfShiftsThatAskedNotToBeAndGot()
        {
            return m_TotalNumberOfShiftsGot != 0
           ? (double)m_ShiftsThatAskedNotToBeAndGot / (double)m_TotalNumberOfShiftsGot * 100
           : 0;
        }

        public ApplWorkerStatInWeek DeepClone()
        {
            MemoryStream ms = new MemoryStream();
            BinaryFormatter bf = new BinaryFormatter();
            bf.Serialize(ms, this);
            ms.Position = 0;
            ApplWorkerStatInWeek obj = (ApplWorkerStatInWeek)bf.Deserialize(ms);
            ms.Close();
            return obj;
        }

    }
}
